package org.alex.farouq.exam.model.question;

import java.util.ArrayList;

/**
 * 
 * @author Ahmed abdl wahab
 * @email ahmed.mail.eg@gmail.com
 * @since 7-Nov-2011
 */
public class MultipleChoice extends Question{

	private QuestionHeader questionHeader;
	private ArrayList<SubQuestion> subQuestions;
	

	public QuestionHeader getQuestionHeader() {
		return questionHeader;
	}


	public void setQuestionHeader(QuestionHeader questionHeader) {
		this.questionHeader = questionHeader;
	}


	public ArrayList<SubQuestion> getSubQuestions() {
		return subQuestions;
	}


	public void setSubQuestions(ArrayList<SubQuestion> subQuestions) {
		this.subQuestions = subQuestions;
	}
	
	public String toString(){
		if((null==getQuestionType())||
			(null==getChoiceListingStyle())||
			(null==getQuestionListingStyle())||
			(null==getQuestionHeader())||
			(null==getSubQuestions()))
			return null;
		StringBuilder subQuestionXML = new StringBuilder();
		for(SubQuestion subQuestion: getSubQuestions()) subQuestionXML.append(subQuestion);
		return "<Question>"+getQuestionType()+getChoiceListingStyle()+getQuestionListingStyle()+getQuestionHeader()+subQuestionXML+"</Question>";
	}
	
	public int getSubQuestionsCount(){
		return subQuestions.size();
	}
	
	public int getChoiceCountAtSubQuestionsIndex(int subQuestionIndex){
		SubQuestion subQuestion = subQuestions.get(subQuestionIndex);
		return subQuestion.getChoicesCount();
	}
	
}
